package com.z4.nordicchinese;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class SLTab extends Activity {
	/** Called when the activity is first created. */
	private WebView webView;
	private String u ="http://mobil.sl.se/";
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...",
				true);

		if (webView == null)
			webView = new WebView(this);
		// webView = (WebView)findViewById(R.id.webView);
		// webView.restoreState(savedInstanceState);
		if (savedInstanceState != null && webView != null) {
			webView.restoreState(savedInstanceState);
		} else {
			webView.setWebViewClient(new WebViewClient() {
				@Override
				public void onPageFinished(WebView view, String url) {
					if (pd.isShowing() && pd != null) {
						pd.dismiss();
					}
				}
			});
			webView.getSettings().setJavaScriptEnabled(true);
			webView.loadUrl(u);
			setContentView(webView);
		}

	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (webView != null && (keyCode == KeyEvent.KEYCODE_BACK||keyCode == KeyEvent.KEYCODE_ESCAPE) && webView.canGoBack()) {
			webView.goBack();
		    return true;
		}
		return super.onKeyDown(keyCode, event);
	}
	
	public void onDestroy()
	{
		super.onDestroy();
	}

	public void onResume()
	{
		super.onResume();
	}
    protected void onPause() {
 		// TODO Auto-generated method stub
 		super.onPause();

 	}
	protected void onSaveInstanceState(Bundle outState) {
		webView.saveState(outState);
	}
}